Here you have some brief comments about each line in the code
of Guardian Soldier:



.- Line #1 ****************************

10 SCREEN1,1,0:DEFINTA-Z:DIMC(18),PD$(6),ES(11),EC(11),EX(11),EY(11),SX(17):A$="":E$="":F$="":G$=STRING$(26,168):COLOR,1,1:KEYOFF:WIDTH32:SPRITEON:ONSPRITEGOSUB80:FORT=1024TO1407:VPOKET,0:NEXT:FORT=0TO63:READA:VPOKE14336+T,A:NEXT

This line sets up the screen mode, initializes arrays, define
sprites, and initializes sprite collision. It is the only
line inside the listing that just executes once.



.- Line #2 ****************************

20 FORT=0TO17:READA:C(T)=A:NEXT:LOCATE3,3:PRINTA$+E$+A$:FORT=1TO16:PRINT"   ";TAB(28);"":NEXT:PRINTTAB(3);A$+F$+A$:LOCATE0,8:FORT=1TO8:PRINT"   ɐ";TAB(28);"":NEXT:LOCATE3,22:PRINTG$:FORT=0TO1:PUTSPRITE2+T,(200+T*24,0),1,4+T:NEXT:LI=6878:X=120:Y=88

Here the screen draws, the sprites for the items are placed and
some initial values for the game are set.



.- Line #3 ****************************

30 Z$="418438468467440C20C63C59C39C474B94C860A523568564559CA8CD8D104816126145225795685C8C38CD9D986396C96A86595B8558C39CE8CD8D996B86796786D8588599C81612C82D996996A36E96E86595816386C0D25DC9698D21D79D526A86696C8D38D53D996A9641DA8DE8D68D69D68DE9DE8DC8":J=13

This is the map definition. Each room uses 3 characters for
its data. The J value is set to the starting room.

ROOM DEFINITION VALUES:
character #1.- Wall color.
character #2.- Sets the exits of the room (data as a nibble, each
bit represents North, East, South and West exits. When the bit is
set, it means an exit exists)
character #3.- The objet in the room (empty, key, knife, clock,
keyholes, orcs or princess)



.- Line #4 ****************************

40 VPOKE8213,9:FORT=1TO5:VPOKE8207+T,0:NEXT:VPOKE6919,0:VPOKE6915,0:PD$(1)=MID$(Z$,J,1):PD$(6)=MID$(Z$,J+2,1):T$=RIGHT$("000"+BIN$(VAL("&h"+MID$(Z$,J+1,1))),4):FORT=1TO4:PD$(1+T)=MID$(T$,T,1):NEXT:FORT=2TO5:IFPD$(T)="0"THENPD$(T)=PD$(1):NEXTELSENEXT

Screen gets all black while data for the room is being
processed.



.- Line #5 ****************************

50 FORT=1TO5:VPOKE8207+T,VAL("&h"+PD$(T)):NEXT:LI=LI-1:VPOKELI,32:RESTORE110:FORT=0TO10:READEX(T),EY(T),EC(T),ES
(T):NEXT:FORT=0TO15:READA:SX(T)=A:NEXT:W=VAL("&H"+PD$(6)):XW=EX(W):YW=EY(W):CW=EC(W):SW=ES(W):PUTSPRITE1,(XW,YW),CW,SW

The room appears with the colors active, showing all its
exits, and the object sprite is shown.



.- Line #6 ****************************

60 L=VPEEK((X/8)+SX(A)+((INT(Y/8)+SX(A+1))*32)+6144):I=0:IFL=136ANDPD$(2)="1"THENJ=J-30:Y=140:I=1ELSEIFL=144ANDPD$(3)="1"THENJ=J-3:X=204:I=1ELSEIFL=152ANDPD$(4)="1"THENJ=J+3:X=32:I=1ELSEIFL=160ANDPD$(5)="1"THENJ=J+30:Y=32:I=1ELSEIFL<>32THENX=XO:Y=YO

Collision detection with walls, and change room detection (variable
I sets to 1 if a new room needs to be created).



.- Line #7 ****************************

70 IFLI<6852THEN110ELSEIFI=1THEN40ELSEXO=X:YO=Y:A=STICK(0)*2:X=X+C(A):Y=Y+C(A+1):PUTSPRITE0,(X,Y),15,P:P=(P+1)AND1:IFW=8ORW=9THENXW=XW+((((X<XW)*2)+1)*(W-7)):YW=YW+((((Y<YW)*2)+1)*(W-7)):PUTSPRITE1,(XW,YW),CW,SW+P:PLAY"o"+STR$(3+P)+"c64":GOTO60ELSE60

Main character movement and enemy movement if any.



.- Line #8 ****************************

80 VPOKE6918,8:SW=8:IFW=1THENVPOKE6923,11:RETURNELSEIFW=2THENVPOKE6927,7:RETURNELSEIFW=3THENLI=6877:LOCATE3,22:PRINTG$:RETURNELSEIF(W=8ORW=9)ANDVPEEK(6927)=1THENLI=LI-1:VPOKELI,32:W=0:RETURNELSEIFW=0THENRETURN

This is the routine accesed by the sprite colision detection.
Here, the colision with a key, knife, clock and enemy (with
no knife) are handled.



.- Line #9 ****************************

90 IFW=10THENLOCATE9,15:PRINT"LOVE IS FOREVER!":GOTO110ELSEIFW=8ORW=9THENVPOKE6927,1:W=0:RETURN:ELSEIFVPEEK(6923)=1THENVPOKE6918,4:RETURNELSEVPOKE6923,1:PD$(W-2)="1":RETURN

Here the colision handler continues, managing the princess
and the enemy colision having the knife.



.- Line #10 ****************************

100 DATA24,24,60,90,56,40,104,12,24,24,60,90,28,20,22,48,0,36,60,24,126,24,52,6,0,36,60,24,126,24,44,96,56,40,56,16,16,24,16,0,16,16,56,0,16,16,16,0,0,126,36,36,24,36,60,126,36,24,60,90,24,60,60,126,0,0,0,-4,4,-4,4,0,4,4,0,4,-4,4,-4,0,-4,-4

This is the sprite graphic data and the C array data for
the main character moves.



.- Line #11 ****************************

110 DATA0,0,0,0,120,88,11,4,120,88,7,5,120,88,9,6,120,18,14,4,24,88,14,4,232,88,14,4,120,158,14,4,120,88,3,2,120,88,2,2,120,88,13,7,0,0,1,0,2,0,2,1,2,2,1,2,0,2,0,1:PLAY"L4O2BAG":FORT=1TO497:COLOR,,T AND7:NEXT:RESTORE100:FORT=0TO63:READA:NEXT:GOTO20

This is the sprite position data and the data for wall
checking. Game over and ending color flash is here too.

